import config from "@/config"
import http from "@/utils/request"
export const showPageApi = {
    url: `${config.BASE_URL}/retire/page/getlist`,
    name: "展示页面数据",
    get: async function(data){
        return await http.get(`${this.url}/${data.pageNum}/${data.pageSize}`);

    }
}

// 导出兵役信息列表
export async function exportApi() {
    let res = await fetch(`${config.BASE_URL}/retire/export`, {
        method: 'post',
        headers: {
            'Content-Type': 'application/json',
        }
    }).then(res => res.blob()).then(data => {
        var blobUrl = window.URL.createObjectURL(data);
        return blobUrl
    })
    return res
}

export const editFormInfoApi= {
    url: `${config.BASE_URL}/retire/getInfo`,
    name: "获取编辑数据的信息",
    get: async function(id){
        return await http.get(`${this.url}/${id}`);
    }
}

export const editFormApi= {
    url: `${config.BASE_URL}/retire/update`,
    name: "点击确定按钮成功编辑",
    put: async function(data){
        return await http.put(`${this.url}`,data);
    }
}

export const addInfoApi= {
    url: `${config.BASE_URL}/retire/add`,
    name: "点击确定按钮成功编辑",
    post: async function(data){
        return await http.post(`${this.url}`,data);
    }
}

export const deleteApi= {
    url: `${config.BASE_URL}/retire/removeById`,
    name: "删除单条数据",
    delete: async function(id){
        return await http.delete(`${this.url}/${id}`);
    }
}

export const allDeleteApi= {
    url: `${config.BASE_URL}/retire/removeByIds`,
    name: "批量删除",
    delete: async function(data){
        return await http.delete(`${this.url}`,data);
    }
}

export const singleSearchApi= {
    url: `${config.BASE_URL}/retire/select/condition`,
    name: "单字段查询",
    post: async function(content,field){
        return await http.post(`${this.url}?condition=${field}&content=${content}`);
    }
}

export const allSearchApi= {
    url: `${config.BASE_URL}/retire/select/advance`,
    name: "高级查询",
    post: async function(data){
        return await http.post(`${this.url}`,data);
    }
}
